# -*- coding: utf-8 -*-
import pygal
from die import Die
# 创建2个骰子
d6 = Die()
d10 = Die(10)
# 掷若干次骰子，并将结果保存
results = []
for roll_num in range(50000):
    result = d6.roll() + d10.roll()
    results.append(result)
# 分析结果
frequencies = []
for value in range(2, d6.num_sides+d10.num_sides+1):
    frequency = results.count(value)
    frequencies.append(frequency)
# print(frequencies)
# 对结果进行可视化
hist = pygal.Bar()
hist.title = "Result of rolling a D6 and a D10 50,000 times."
hist.x_labels = ['2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16']
hist.x_title = "Result"
hist.y_title = "Frequency of Result"
hist.add('D6 + D10', frequencies)
# 将结果显示成svg
hist.render_to_file('die_visual.svg')
